home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) Mar, 1986 UMMC. All rights reserved
-
- Filename: mkmxl.c
-
- Abstract: This module contains the code to construct the matrices used to transform between
- The LAT image coordinates and the patient/table coordinates
-
- Environment: UM/CLIP
-
- Revision History:
- Rev # Date Auth Reason
- ----- --------- ----- ----------------------------------
- 0.0 17-mar-86 js original implementation
- 0.1 28-apr-86 js converted to double precision
-
- -----------------------------------------------------------------------------------------
- NAME:
- mkmxl - make coordinate transform matrices (LAT)
-
- SYNOPSIS:
-
- ERRCODE mkmxl (alpha, beta, l2p, p2l)
-
- INT alpha; angle alpha for the LAT C-arm
- INT beta; angle beta for the LAT C-arm
- DOUBLE l2p[9]; array for 'LAT to patient' transform matrix
- DOUBLE p2l[9]; array for 'patient to LAT' transform matrix
-
- MODIFIED ARGUMENTS:
-
- l2p and p2l will contain the transform matrices corresponding to angles alpha and beta
-
- FUNCTION:
-
- Matrix methods are used in order to implement transformations between the coordinate
- systems subtended by the LAT image plane and the patient. It is the function of this
- routine to construct the required matrices based on the angulation of the C-arm. The
- form of the matrices is the following (a = alpha & b = beta):
-
- p2l:
-
- -cos a sin b -cos b sin a sin b
- -sin a 0 -cos a
- -cos a cos b sin b sin a cos b
-
- l2p:
-
- -cos a sin b -sin a -cos a cos b
- -cos b 0 sin b
- sin a sin b -cos a sin a cos b
-
- PROGRAMMING NOTES:
-
- The elements of the matrices will be stored as sequential rows in the array.
-
- EXAMPLES:
-
- =========================================================================*/
-
- #include "clipinclude.h"
-
- ERRCODE mkmxl (alpha, beta, l2p, p2l)
-
- INT alpha; /* angle alpha for the LAT C-arm */
- INT beta; /* angle beta for the LAT C-arm */
- DOUBLE l2p[9]; /* array for 'LAT to patient' transform matrix */
- DOUBLE p2l[9]; /* array for 'patient to LAT' transform matrix */
-
- {
-
- DOUBLE sina, cosa; /* sine and cosine of alpha */
- DOUBLE sinb, cosb; /* sine and cosine of beta */
- ERRCODE erret = OK; /* error code */
-
- DOUBLE sin (); /* sine function */
- DOUBLE cos (); /* cosine function */
-
- /* get copies of sine's and cosine's */
-
- sina = sin((DOUBLE)alpha * Pi / 180);
- cosa = cos((DOUBLE)alpha * Pi / 180);
- sinb = sin((DOUBLE)beta * Pi / 180);
- cosb = cos((DOUBLE)beta * Pi / 180);
-
- /* construct matrices */
-
- p2l[0] = l2p[0] = -cosa * sinb;
- p2l[1] = l2p[3] = -cosb;
- p2l[2] = l2p[6] = sina * sinb;
- p2l[3] = l2p[1] = -sina;
- p2l[4] = l2p[4] = 0;
- p2l[5] = l2p[5] = -cosa;
- p2l[6] = l2p[2] = -cosa * cosb;
- p2l[7] = l2p[5] = sinb;
- p2l[8] = l2p[8] = sina * cosb;
-
- /* all done */
-
- return (erret);
-
- }